		<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <ext:ResourceManager ID="ResourceManagerProxy1" runat="server">
    </ext:ResourceManager>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <ext:Viewport ID="ViewPort1" runat="server" Layout="fit">
        <Items>
            <ext:FormPanel ID="pnlAddOrderitem" runat="server" Title="新增orderitem信息" Frame="true" ButtonAlign="Center">
                <Items>
										    <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtId" runat="server" FieldLabel="Id" AllowBlank="False" BlankText="请输入Id！"   Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
    <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtOrderId" runat="server" FieldLabel="OrderId"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
    <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtProductID" runat="server" FieldLabel="ProductID"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
    <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtItemCount" runat="server" FieldLabel="ItemCount"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
    <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtItemName" runat="server" FieldLabel="ItemName"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
    <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtPrice" runat="server" FieldLabel="Price"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
    <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtAmount" runat="server" FieldLabel="Amount"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
    <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtLineTotal" runat="server" FieldLabel="LineTotal"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
    <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtLineActual" runat="server" FieldLabel="LineActual"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
    <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtLineVoucher" runat="server" FieldLabel="LineVoucher"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
    <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtComment" runat="server" FieldLabel="Comment"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>

                </Items>
                <Buttons>
                    <ext:Button runat="server" Text="保存"  Icon="Accept">
                        <DirectEvents>
                            <Click Before="if(!#{pnlAddOrderitem}.getForm().isValid()) return false;" OnEvent="btnAddOrderitem_Click"
                                Success="#{pnlAddOrderitem}.getForm().reset();parent.ShowMessage('操作成功','添加orderitem成功！',1);parent.RefreshOrderitemData();parent.CloseAddOrderitem(); "
                                 Failure="Ext.Msg.alert('操作失败', result.errorMessage);">
                                <EventMask ShowMask="true" Msg="数据保存中,请稍等....." />
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                    <ext:Button runat="server" Text="取消" Icon="Decline">
                        <Listeners>
                            <Click Handler="parent.CloseAddOrderitem();"></Click>
                        </Listeners>
                    </ext:Button>
                </Buttons>
            </ext:FormPanel>
        </Items>
    </ext:Viewport>
</asp:Content>

	    protected void Page_Load(object sender, EventArgs e)
        {
            if (X.IsAjaxRequest)
                return;
 
        }

        protected void btnAddOrderitem_Click(object sender, DirectEventArgs e)
        {
            try
            {
                Orderitem newOrderitem = new Orderitem();

                
										   newOrderitem.Id = this.txtId.Text.Trim();
   newOrderitem.OrderId = this.txtOrderId.Text.Trim();
   newOrderitem.ProductID = this.txtProductID.Text.Trim();
   newOrderitem.ItemCount = this.txtItemCount.Text.Trim();
   newOrderitem.ItemName = this.txtItemName.Text.Trim();
   newOrderitem.Price = this.txtPrice.Text.Trim();
   newOrderitem.Amount = this.txtAmount.Text.Trim();
   newOrderitem.LineTotal = this.txtLineTotal.Text.Trim();
   newOrderitem.LineActual = this.txtLineActual.Text.Trim();
   newOrderitem.LineVoucher = this.txtLineVoucher.Text.Trim();
   newOrderitem.Comment = this.txtComment.Text.Trim();



                Global.CurrentServiceContainer.OrderitemServiceProxy.Insert(newOrderitem);
 
                ResourceManager.AjaxSuccess = true;
 
            }
            catch (Exception ex)
            {
                ResourceManager.AjaxSuccess = false;
                ResourceManager.AjaxErrorMessage = "Error Message:" + ex.Message;
            }

        } 
			
